#pragma once

#include "commonheader.h"


typedef void(*AcceptCB)(SOCKET sClient, SOCKADDR_IN clientAddr);

class CListenSocket
{
public:
	CListenSocket(USHORT nPort, AcceptCB callback);
	virtual ~CListenSocket();

	BOOL Start();
	void Exit();
	void AcceptClient();

private:
	WSAEVENT mEvent;
	SOCKET  mListenSocket;
	std::thread	*mListenThread;
	BOOL	mIsAlive;
	USHORT	mPort;
	AcceptCB mCallBack;

	static void ListenThread(LPVOID argv1);
};